﻿using Client.IDAL;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;

namespace Client.DAL {
  public class UserDAL : WebDataAccess, IUserDAL {
    public Task<string> GetAll() {
      return GetData("user/all");
    }

    public Task<string> GetRolesByUserId(int userId) {
      return GetData($"user/roles/{userId}");
    }

    public Task ResetPassword(string userId) {
      Dictionary<string, HttpContent> param = new Dictionary<string, HttpContent>();
      param.Add("userId", new StringContent(userId));
      return PostData($"user/resetpwd", param);
    }

    public Task SaveUser(string data) {
      StringContent content = new StringContent(data);
      content.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue("application/json");
      return PostData($"user/save", content);
    }
  }
}
